<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 可以在模板中通过 $event 获取到事件对象 -->
      <p id="hehe" v-on:click="onClick($event)">{{ msg }}</p>
    </div>

    <script src="../vue.js"></script>
    <script>
      var app = new Vue({
        el: '#app',
        data: {
          msg: 'hehe',
        },
        methods: {
          onClick(e) {
            console.log('触发了点击事件');
            console.log('事件对象：', e);
            console.log('事件目标：', e.target);
            console.log('事件目标的ID为：', e.target.id);
          },
        },
      });
    </script>
  </body>
</html>
